package components.scanario.elements
{
	import UIFree.ObjectEvent;
	import UIFree.uif_Timer;
	
	import classes.c_events;
	
	import components.scanario.c_scenarioManager;
	import components.scanario.scenaries.c_baseScenario;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;

	public class c_waitElement extends c_scenarioElem {
		
		private var _sc		: c_scenarioManager;
		private var _timer	: uif_Timer;
		private var _check	: Function;
		public function c_waitElement(a_sc: c_baseScenario, a_description:String, a_chek: Function) {
			super(a_sc, a_description);
			_check 	= a_chek;
			_sc 	= a_sc;
			_timer 	= new uif_Timer(300, doCheckCondition);
			_timer.start();
		}
		
		override protected function doCheck(obj:Object):Boolean {
			return false;
		}
		
		private function doCheckCondition(e: Event): void {
			if ((_sc.curElement == this) && checkCondition()) _sc.nextElement();
		}
			
		protected function checkCondition(): Boolean {
			return _check();
		}
	}
}